#include "intro.h"
#include <QMenuBar>
#include <QPainter>
#include <QDebug>
#include "mypushbotton.h"
#include "playscene.h"
#include <QTimer>
#include <QGraphicsTextItem>

intro::intro(QWidget *parent) : QMainWindow(parent)
{
    initScene();



    //创建菜单栏
   /*QMenuBar *bar = menuBar();
   setMenuBar(bar);
   QMenu *startMenu = bar->addMenu("Start");
   QAction * quitAction = startMenu->addAction("Exit");
   connect(quitAction, &QAction::triggered,[=](){
       this->close();
   });*/

    play = new PlayScene;
    myPushBotton * out = new myPushBotton(":/resource/exit.png");
    out->setParent(this);
    out->move(this->width()*0.5 - out -> width()*0.5,this->height()*0.8);
    connect(out,&myPushBotton::clicked,[=](){
        qDebug()<<"点击了退出";
        out->zoom1();
        out->zoom2();
        ///////////////////////
        //进入下一个场景
        QTimer::singleShot(1000,this,[=](){
            this->close();
        });
    });
    myPushBotton * ctn = new myPushBotton(":/resource/continue.png");
    ctn->setParent(this);
    ctn->move(this->width()*0.5- ctn->width()*0.5, this->height()*0.6);
    connect(ctn, &myPushBotton::clicked,[=](){
        qDebug()<<"点击了继续";
        ctn->zoom1();
        ctn->zoom2();
        int elation = 0;
        int grief = 0;
        int peace = 0;
        int mania = 0;
        qDebug()<<"elation "<<elation<<"grief "<<grief<<"peace "<<peace<<"mania "<<mania;
        QTimer::singleShot(1000,this,[=](){
            this->hide();
            play->show();
        });
    });

}
void intro::initScene()
{
    setFixedSize(gamew,gameh);
    setWindowIcon(QPixmap(gameicon));
    setWindowTitle(gametitle);
}
void intro::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(introimg);
    painter.drawPixmap(0,0,pix);
    pix.load(":/resource/pub5.jpg");
    painter.drawPixmap(0,0,pix);
}
